﻿<%@ Page Language="C#" MasterPageFile="~/MainPage.master" AutoEventWireup="true"
    CodeFile="Orders.aspx.cs" Inherits="Orders" Title="Orders" %>

<asp:Content ID="webOrdersTitle" ContentPlaceHolderID="cphTitle" runat="server">
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">
                Orders
            </h1>
            <ol class="breadcrumb">
                <li><i class="fa fa-home"></i><a href="Home.aspx">Home</a> </li>
                <li class="active"><i class="fa fa-file"></i>Orders </li>
            </ol>
        </div>
    </div>
</asp:Content>
<asp:Content ID="webOrders" ContentPlaceHolderID="cphMainPage" runat="Server">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <link href="css/CSSGridView1.css" rel="stylesheet" type="text/css" />

        <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

        <script src="Scripts/jquery.dynDateTime.min.js" type="text/javascript"></script>

        <script src="Scripts/calendar-en.min.js" type="text/javascript"></script>

        <link href="Styles/calendar-blue.css" rel="stylesheet" type="text/css" />

        <script type="text/javascript">
    $(document).ready(function () {
        $("#<%=txtOrderDate.ClientID %>").dynDateTime({
            showsTime: false,
            ifFormat: "%m/%d/%Y",
            daFormat: "%l;%M %p, %e %m,  %Y",
            align: "BR",
            electric: false,
            singleClick: false,
            displayArea: ".siblings('.dtcDisplayArea')",
//            button: ".next()"
        });
    });
    
    $(document).ready(function () {
        $("#<%=txtRequiredDate.ClientID %>").dynDateTime({
            showsTime: false,
            ifFormat: "%m/%d/%Y",
            daFormat: "%l;%M %p, %e %m,  %Y",
            align: "BR",
            electric: false,
            singleClick: false,
            displayArea: ".siblings('.dtcDisplayArea')",
//            button: ".next()"
        });
    });
    
    $(document).ready(function () {
        $("#<%=txtShippedDate.ClientID %>").dynDateTime({
            showsTime: false,
            ifFormat: "%m/%d/%Y",
            daFormat: "%l;%M %p, %e %m,  %Y",
            align: "BR",
            electric: false,
            singleClick: false,
            displayArea: ".siblings('.dtcDisplayArea')",
//            button: ".next()"
        });
    });
    
     $(document).ready(function () {
        $("#<%=txtDateSearchFrom.ClientID %>").dynDateTime({
            showsTime: false,
            ifFormat: "%m/%d/%Y",
            daFormat: "%l;%M %p, %e %m,  %Y",
            align: "BR",
            electric: false,
            singleClick: false,
            displayArea: ".siblings('.dtcDisplayArea')",
//            button: ".next()"
        });
    });
    
     $(document).ready(function () {
        $("#<%=txtDateSearchTo.ClientID %>").dynDateTime({
            showsTime: false,
            ifFormat: "%m/%d/%Y",
            daFormat: "%l;%M %p, %e %m,  %Y",
            align: "BR",
            electric: false,
            singleClick: false,
            displayArea: ".siblings('.dtcDisplayArea')",
//            button: ".next()"
        });
    });
    
    
        </script>

        <title>Orders</title>
    </head>
    <body>
        <%--<form id="form1" runat="server">--%>
        <div>
            <table>
                <table>
                    <tr>
                        <td>
                            Order ID:
                        </td>
                        <td style="width: 184px">
                            <asp:TextBox ID="txtOrderID" runat="server" Style="height: 22px" Width="100%" Enabled="False"></asp:TextBox>
                        </td>
                        <td style="width: 109px">
                        </td>
                        <td>
                            Freight:
                        </td>
                        <td style="width: 184px">
                            <asp:TextBox ID="txtFreight" runat="server" Width="100%" MaxLength="99999999"></asp:TextBox>
                        </td>
                        <td style="width: 117px">
                            &nbsp;
                            <asp:RequiredFieldValidator ID="reqFreight" runat="server" ControlToValidate="txtFreight"
                                Display="Dynamic" ErrorMessage="Required Field!"></asp:RequiredFieldValidator>
                            <asp:RangeValidator ID="valFreight" runat="server" ControlToValidate="txtFreight"
                                Display="Dynamic" ErrorMessage="Enter positive number!" MaximumValue="999999"
                                MinimumValue="0" Type="Double"></asp:RangeValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Customer:
                        </td>
                        <td style="width: 184px">
                            <asp:DropDownList ID="ddlCustomer" runat="server" Width="100%" DataTextField="companyname"
                                DataValueField="custid">
                            </asp:DropDownList>
                            <%--<asp:SqlDataSource ID="ddlCustomersDB" runat="server" ConnectionString="<%$ ConnectionStrings:conStr %>"
                                SelectCommand="SELECT custid, companyname FROM Sales.Customers"></asp:SqlDataSource>  DataSourceID="ddlCustomersDB" --%>
                        </td>
                        <td style="width: 109px">
                        </td>
                        <td>
                            Ship Name:
                        </td>
                        <td style="width: 184px">
                            <asp:TextBox ID="txtShipName" runat="server" Width="100%" MaxLength="40"></asp:TextBox>
                        </td>
                        <td style="width: 117px">
                            &nbsp;
                            <asp:RequiredFieldValidator ID="reqShipName" runat="server" ControlToValidate="txtShipName"
                                Display="Dynamic" ErrorMessage="Required Field!"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Employee:
                        </td>
                        <td style="width: 184px">
                            <asp:DropDownList ID="ddlEmployee" runat="server" Width="100%">
                            </asp:DropDownList>
                            <%-- <asp:SqlDataSource ID="ddlEmployeesDB" runat="server" ConnectionString="<%$ ConnectionStrings:conStr %>"
                                SelectCommand="SELECT empid, firstname + ' ' + lastname AS fullname FROM HR.Employees">
                            </asp:SqlDataSource> DataSourceID="ddlEmployeesDB  DataTextField="fullname" DataValueField="empid"--%>
                        </td>
                        <td style="width: 109px">
                        </td>
                        <td>
                            Ship Address:
                        </td>
                        <td style="width: 184px">
                            <asp:TextBox ID="txtShipAddress" runat="server" Width="100%" MaxLength="60"></asp:TextBox>
                        </td>
                        <td style="width: 117px">
                            &nbsp;
                            <asp:RequiredFieldValidator ID="reqShipAddress" runat="server" ControlToValidate="txtShipAddress"
                                Display="Dynamic" ErrorMessage="Required Field!"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Order Date:
                        </td>
                        <td style="width: 184px">
                            <asp:TextBox ID="txtOrderDate" runat="server" Width="100%"></asp:TextBox>
                        </td>
                        <td style="width: 109px">
                            <asp:RequiredFieldValidator ID="reqOrderDate" runat="server" ErrorMessage="Required Field!"
                                ControlToValidate="txtOrderDate" Display="Dynamic"></asp:RequiredFieldValidator>
                        </td>
                        <td>
                            Ship City:
                        </td>
                        <td style="width: 184px">
                            <asp:TextBox ID="txtShipCity" runat="server" Width="100%" MaxLength="15"></asp:TextBox>
                        </td>
                        <td style="width: 117px">
                            &nbsp;
                            <asp:RequiredFieldValidator ID="reqShipCity" runat="server" ControlToValidate="txtShipCity"
                                Display="Dynamic" ErrorMessage="Required Field!"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td class="style4">
                            Required Date:
                        </td>
                        <td style="width: 184px">
                            <asp:TextBox ID="txtRequiredDate" runat="server" Width="100%"></asp:TextBox>
                        </td>
                        <td class="style1" style="width: 109px">
                            <asp:RequiredFieldValidator ID="reqRequiredDate" runat="server" ErrorMessage="Required Field!"
                                ControlToValidate="txtRequiredDate" Display="Dynamic"></asp:RequiredFieldValidator>
                            <asp:CompareValidator ID="cvalRequiredDate" runat="server" ControlToCompare="txtOrderDate"
                                ControlToValidate="txtRequiredDate" Display="Dynamic" ErrorMessage="RequiredDate&gt;=OrderDate"
                                Operator="GreaterThanEqual" Type="Date"></asp:CompareValidator>
                        </td>
                        <td>
                            Ship Region:
                        </td>
                        <td style="width: 184px">
                            <asp:TextBox ID="txtShipRegion" runat="server" Width="100%" MaxLength="15"></asp:TextBox>
                        </td>
                        <td style="width: 117px">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Shipped Date:
                        </td>
                        <td style="width: 184px">
                            <asp:TextBox ID="txtShippedDate" runat="server" Width="100%"></asp:TextBox>
                        </td>
                        <td style="width: 109px">
                            <asp:CompareValidator ID="cvalShippedDate" runat="server" ControlToCompare="txtOrderDate"
                                ControlToValidate="txtShippedDate" Display="Dynamic" ErrorMessage="ShippedDate&gt;=OrderDate"
                                Operator="GreaterThanEqual" Type="Date"></asp:CompareValidator>
                        </td>
                        <td>
                            Ship Postal Code:
                        </td>
                        <td style="width: 184px">
                            <asp:TextBox ID="txtShipPostalCode" runat="server" Width="100%" MaxLength="10"></asp:TextBox>
                        </td>
                        <td style="width: 117px">
                            &nbsp;
                            <asp:RangeValidator ID="valPostalCode" runat="server" ControlToValidate="txtShipPostalCode"
                                Display="Dynamic" ErrorMessage="Code must be number!" 
                                MaximumValue="999999" MinimumValue="0" Type="Integer"></asp:RangeValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Shipper:
                        </td>
                        <td style="width: 184px">
                            <asp:DropDownList ID="ddlShipper" runat="server" Width="100%">
                            </asp:DropDownList>
                            <%-- <asp:SqlDataSource ID="ddlShippersDB" runat="server" ConnectionString="<%$ ConnectionStrings:conStr %>"
                                SelectCommand="SELECT shipperid, companyname FROM Sales.Shippers"></asp:SqlDataSource> DataSourceID="ddlShippersDB"
                                DataTextField="companyname" DataValueField="shipperid"--%>
                        </td>
                        <td style="width: 109px">
                        </td>
                        <td>
                            Country:
                        </td>
                        <td style="width: 184px">
                            <asp:DropDownList ID="ddlCountry" runat="server" Width="100%" DataSourceID="countriesXML"
                                DataTextField="name" DataValueField="name">
                            </asp:DropDownList>
                            <asp:XmlDataSource ID="countriesXML" runat="server" DataFile="~/App_Data/countries.xml">
                            </asp:XmlDataSource>
                        </td>
                        <td style="width: 117px">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 30px">
                        </td>
                        <td style="width: 184px; height: 30px;">
                        </td>
                        <td style="width: 109px; height: 30px;">
                        </td>
                        <td style="height: 30px">
                        </td>
                        <td style="width: 184px; height: 30px;">
                        </td>
                        <td style="width: 117px; height: 30px;">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td colspan="5">
                            <asp:Button ID="btnNew" runat="server" Text="New" Width="65px" OnClick="btnNew_Click"
                                CausesValidation="False" />
                            <asp:Button ID="btnAdd" runat="server" Text="Add" Width="65px" OnClick="btnAdd_Click"
                                Height="26px" />
                            <asp:Button ID="btnUpdate" runat="server" Text="Update" Width="65px" Enabled="False"
                                OnClick="btnUpdate_Click" />
                            <asp:Button ID="btnDelete" runat="server" Text="Delete" Width="65px" Enabled="False"
                                OnClick="btnDelete_Click" CausesValidation="False" />
                            <asp:Button ID="btnDetail" runat="server" CausesValidation="False" 
                                onclick="btnDetail_Click" Text="Details" />
                        </td>
                        <td style="width: 117px">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td colspan="5" style="height: 30px">
                        </td>
                        <td style="height: 30px; width: 117px;">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6" style="height: 26px">
                            <asp:Label ID="Label1" runat="server" Text="Search by:"></asp:Label>
                            <asp:DropDownList ID="ddlSearch" runat="server" OnTextChanged="ddlSearch_TextChanged"
                                AutoPostBack="true">
                                <asp:ListItem>Order ID</asp:ListItem>
                                <asp:ListItem>Customer</asp:ListItem>
                                <asp:ListItem>Employee</asp:ListItem>
                                <asp:ListItem>Order Date</asp:ListItem>
                                <asp:ListItem>Required Date</asp:ListItem>
                                <asp:ListItem>Shipped Date</asp:ListItem>
                                <asp:ListItem>Not yet Shipped</asp:ListItem>
                            </asp:DropDownList>
                            <asp:Label ID="lblSearchFrom" runat="server" Text="From:" Visible="False"></asp:Label>
                            <asp:TextBox ID="txtDateSearchFrom" runat="server" Visible="False"></asp:TextBox>
                            <asp:Label ID="lblSearchTo" runat="server" Text="To:" Visible="False"></asp:Label>
                            <asp:TextBox ID="txtDateSearchTo" runat="server" Visible="False"></asp:TextBox>
                            <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
                            <asp:DropDownList ID="ddlSearchValue" runat="server" Visible="False">
                            </asp:DropDownList>
                            <asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"
                                CausesValidation="False" />
                            <asp:Button ID="btnReload" runat="server" OnClick="btnReload_Click" Text="Reload"
                                CausesValidation="False" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="5">
                            &nbsp;
                        </td>
                        <td style="width: 117px">
                            &nbsp;
                        </td>
                    </tr>
                </table>
                </tr>
                <tr>
                </tr>
                <tr>
                    <asp:GridView ID="gvOrders" runat="server" AutoGenerateColumns="false" OnPageIndexChanging="gvOrders_PageIndexChanging"
                        OnSelectedIndexChanged="gvOrders_SelectedIndexChanged" 
                CssClass="Grid" AlternatingRowStyle-CssClass="alt"
                        PagerStyle-CssClass="pgr" AllowSorting="True" 
                onsorting="gvOrders_Sorting">
                        <Columns>
                            <asp:BoundField DataField="orderid" HeaderText="Order ID" SortExpression="orderid" />
                            <asp:BoundField DataField="custid" HeaderText="Customer ID" SortExpression="custid" />
                            <asp:BoundField DataField="empid" HeaderText="Employee ID" SortExpression="empid" />
                            <asp:BoundField DataField="orderdate" HeaderText="Order Date" DataFormatString="{0:d}" SortExpression="orderdate" />
                            <asp:BoundField DataField="requireddate" HeaderText="Required Date" DataFormatString="{0:d}" SortExpression="requireddate" />
                            <asp:BoundField DataField="shippeddate" HeaderText="Shipped Date" DataFormatString="{0:d}" SortExpression="shippeddate" />
                            <asp:BoundField DataField="shipperid" HeaderText="Shipper ID" SortExpression="shipperid" />
                            <asp:BoundField DataField="freight" HeaderText="Freight" SortExpression="freight" />
                            <asp:BoundField DataField="shipname" HeaderText="Ship Name" SortExpression="shipname" />
                            <asp:BoundField DataField="shipaddress" HeaderText="Ship Address" SortExpression="shipaddress" />
                            <asp:BoundField DataField="shipcity" HeaderText="Ship City" SortExpression="shipcity" />
                            <asp:BoundField DataField="shipregion" HeaderText="Ship Region" SortExpression="shipregion" />
                            <asp:BoundField DataField="shippostalcode" HeaderText="Ship Postal Code" SortExpression="shippostalcode" />
                            <asp:BoundField DataField="shipcountry" HeaderText="Ship Country" SortExpression="shipcountry" />
                        </Columns>

<PagerStyle CssClass="pgr"></PagerStyle>

<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
                    </asp:GridView>
                </tr>
                <tr>
                </tr>
                <tr>
                    <asp:Label ID="lblNotFound" runat="server"></asp:Label>
                </tr>
            </table>
        </div>
        <%--   </form>--%>
    </body>
    </html>
</asp:Content>
